relative
Get the relative filepath from path A to path B. Calculates from file-to-directory, file-to-file, directory-to-file, and directory-to-directory.
Calculates correctly from:
- File to directory
- File to file
- Directory to file
- Directory to directory
Install
Install with npm:
npm i relative --save-dev
Usage
var relative = require('relative');
relative(from, to);
relative('test/fixtures/foo.txt', 'docs');
API
relative
Return the relative path from a
to b
.
Example:
var relative = require('relative');
relative('test/fixtures/foo.txt', 'docs/new/file.txt');
from
{String}to
{String}return
{String}
.toBase
Get the path relative to the given base path.
Example:
relative.toBase('test/fixtures', 'test/fixtures/docs/new/file.txt');
basepath
{String}: The base directoryfilepath
{String}: The full filepathreturn
{String} The relative path
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on July 06, 2014.